 

function dailyCheckCtrl($scope, $http, ngDialog, paFetchService) {
  'ngInject';
  this.userInfo = {
    // dealType: parseInt(this.userInfo.dealType),
  };
  this.dailyCheckList = {};

  // 分页
  this.paginationData = {
    pageNum: 1,
    pageSize: 10,
    total: '',
  }

  // 页码变化时调用方法
  $scope.pageChange = () => {
    $http.post(`${SERVER_CONTEXT}/api/securityactivities/DailyCheckProblem/queryByCondition`,
      angular.extend(this.userInfo, this.paginationData)
        )
      .then((resp) => {
        if(resp.statusText == 'OK'){
          this.dailyCheckList = resp.data.data;
          this.paginationData.total = resp.data.total;
        }
    });
  };

  // 分页查询方法
  this.paginationQuery = () => {
    console.log(this.userInfo);
    $http.post(`${SERVER_CONTEXT}/api/securityactivities/DailyCheckProblem/queryByCondition`,
      angular.extend(this.userInfo, this.paginationData)
        )
      .then((resp) => {
        if(resp.statusText == 'OK'){
          this.dailyCheckList = resp.data.data;
          this.paginationData.total = resp.data.total;
        }        
    });
  };

  // 查询
  this.query = () => {
    this.paginationQuery();
  } 

  // 重置
  this.reset = () => {
    this.userInfo = {};
  }

  // 删除日常巡查 
  this.deleteDailyCheck = (id) => {
    $scope.modalTitle = '删除日常巡查';
    $scope.modalContent = '确认要删除该信息吗?';
    ngDialog.openConfirm({
      template: 'paConfirm',
      className: 'ngdialog-theme-default pa-confirm-theme',
      scope: $scope,
    }).
      then((value) => {
        $http.delete(`${SERVER_CONTEXT}/api/securityactivities/DailyCheckProblem/deleteDailyCheck/${id}`).
          then((resp) => {
            if (resp.data.success) {
              layer.msg(resp.data.message);
              $state.reload();
            } else {
              layer.alert(resp.data.message);
            }
          });
      }, (reason) => {});
  }

  this.initPage = () => {
    // 获得标段list             
    paFetchService
                  .getSectionList()
                  .then((resp) => {
                    this.sectionList = resp.data;
                  });
    // 获得项目部list
    paFetchService
                  .getOrgList()
                  .then((resp) => {
                    this.orgList = resp.data;
                  });

    // 获取日常巡查分页
    this.paginationQuery();
  }

  // 升序、降序
  this.up = (param,index) => {   
    this.userInfo.columeName = param;
    this.userInfo.order = index;
    this.paginationQuery();
  }

  // 初始化
  this.initPage();

}

export default dailyCheckCtrl;